package com.cnap.model.intelligent;

import cn.hutool.extra.spring.SpringUtil;
import com.cnap.service.StrategyService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 智能调度周期任务
 *
 * @author xc
 **/
public class IntelligentTask implements Runnable {
    private static final Logger LOGGER = LoggerFactory.getLogger(IntelligentTask.class);
    // 微服务id
    private String svcId;
    // cron表达式
    private String cron;

    /**
     * get
     *
     * @return Cron
     */
    public String getCron() {
        return cron;
    }

    /**
     * set
     *
     * @param cron cron
     */
    public void setCron(String cron) {
        this.cron = cron;
    }

    /**
     * get
     *
     * @return SvcId
     */
    public String getSvcId() {
        return svcId;
    }

    /**
     * set
     *
     * @param svcId svcId
     */
    public void setSvcId(String svcId) {
        this.svcId = svcId;
    }


    @Override
    public void run() {
        StrategyService strategyService = SpringUtil.getBean(StrategyService.class);
        strategyService.intelligentScheduleCompare(svcId);
        LOGGER.info("[intelligent-task]: start intelligent schedule, svcId={}", svcId);
    }
}
